<?php include "../../inc/classes.inc" ?>
<?php include "../../inc/constants.inc" ?>
<?php session_start(); ?>
<?php
    
    
    if ( isset($_GET['player_list_id']) == false ) {
    	redirect("/tornooien/zt-php/view_players_list.php");
    }

    $playerListId = $_GET['player_list_id'];

    if ( !isset($_SESSION['user']) || $_SESSION['user']->club_id != 100 ) {
    	$msg = "U hebt geen toelating op deze pagina.";
		redirect("/tornooien/zt-php/view_players_list.php?msg=".$msg);
    }

    $user = $_SESSION['user'];
    
    $connect = mysql_connect(DB_SERVER, DB_USER, DB_PWD);
	mysql_select_db(DB_CATALOG);
	
	$query = "SELECT tournament_id from zt_tournament where isCurrent = 1";
    $result = mysql_query($query, $connect);
    $row = mysql_fetch_assoc($result);
    $currentTournament = $row['tournament_id'];

    // CHANGING LIST

    $action = null;
    if ( isset($_GET['action']) == true ) $action = $_GET['action'];

	if ( isset($_SESSION['players'.$playerListId]) && $action != 'reset' ) {
	    //$changedPlayersListApprove = $_SESSION['players'.$playerListId];
        $changed = true;
	    $playersListApprove = $_SESSION['players'.$playerListId];
	    if ( isset($_GET['row']) == true ) {
	        $row = $_GET['row'];
            if ($action == 'remove') {
                array_deleteobj($playersListApprove, $row - 1);
            } else if ($action == 'up') {
	        	array_switchobj($playersListApprove, $row - 2, $row - 1);
	        } else if ($action == 'down') {
	            array_switchobj($playersListApprove, $row - 1, $row);
	        }
	        $_SESSION['players'.$playerListId] = $playersListApprove;
	    }

	} else {
	    $query = "select zp.index_nr, p.matricule, (select team_nr from zt_team where team_id = zp.team_id) as team_nr,
	        p.nom_prenom, p.elo_calcul, p.club from zt_player_list zpl, zt_player zp, playernew p where zpl.player_list_id =
	        zp.player_list_id and zp.player_key = p.matricule and zpl.player_list_id = ".$playerListId." order by zp.index_nr";

        $playersListApprove = array();
	    if ($result = mysql_query($query, $connect)) {
	        $index = 0;
	        while ($row = mysql_fetch_assoc($result)) {
	            $player = new Player;
	            $player->index_nr = $row['index_nr'];
	            $player->team_name = $row['team_nr'];
	            $player->player_key = $row['matricule'];
	            $player->player_name = $row['nom_prenom'];
	            $player->elo = $row['elo_calcul'];
	            $player->club_id = $row['club'];
	            $player->team_name = $row['team_nr'];
	            $playersListApprove[$index++] = $player;
	        }
	        $_SESSION['players'.$playerListId] = $playersListApprove;
	    }
	}

    $query = "select u.user_id, u.club_id from zt_player_list pl join user u on u.user_id = pl.user_id where pl.player_list_id = ".$playerListId;
    $result = mysql_query($query, $connect);
    $row = mysql_fetch_assoc($result);
    $userId = $row['user_id'];
    $clubId = $row['club_id'];

    $query = "select firstname, lastname, function, email from zt_player_list pl join user u on u.user_id = pl.user_id where pl.player_list_id = ".$playerListId;
    $result = mysql_query($query, $connect);
    $row = mysql_fetch_assoc($result);
    $to = $row['email'];
    //$to = "mordredqv@gmail.com";
    $name = $row['firstname'].' '.$row['lastname'];
    $function = $row['function'];

    $result = mysql_query("SELECT c.clubname from club c join zt_player_list zpl on c.club_id = zpl.club_id
        where zpl.player_list_id = ".$playerListId);
    $row = mysql_fetch_assoc($result);
    $clubname = $row['clubname'];

    $approval = null;
    if ( isset($_GET['approval']) == true ) {
    	$approval = $_GET['approval'];
        $message= $_SESSION['mailMessage'.$playerListId];
	   	//$body = chunk_split(base64_encode($message))."\r\n";
        echo $message.",".$playerListId;
        
	   	$body = "Geachte ".$name.",\r\n".$message."\r\n\r\nU kan uw spelerslijst raadplegen op http://schaakliga-antwerpen.info/tornooien/zt-php/player_list_detail.php?player_list_id="
	   		.$playerListId."\r\n\r\nMet vriendelijke groeten,\r\nPatrick Van de Perre,\r\nTornooileider Schaakliga Antwerpen";
	   	ini_set("SMTP", SMTP_HOST);
	   	ini_set("smtp_port", SMTP_PORT);
	    ini_set("sendmail_from", "tornooileider@schaakliga-antwerpen.info");
        $headers = 'Cc: medewerkertornooileider@schaakliga-antwerpen.info, tornooileider@schaakliga-antwerpen.info;'."\r\n";
        //$headers = 'Cc: medewerkertornooileider@schaakliga-antwerpen.info;'."\r\n";
        $msg = "Spelerslijst kon niet behandeld worden !";

        if ($approval == 'true') {
            
        	$query = "SELECT zpl.player_list_id from zt_player_list zpl JOIN zt_tournament zt ON zt.tournament_id = zpl.tournament_id 
                join club c on c.club_id = zpl.club_id
				where c.club_id = (select club_id from zt_player_list where player_list_id = ".$playerListId.
				") AND zt.isCurrent =1 and date_approved is not null and inactive = 0";
            $result = mysql_query($query, $connect);
            if (mysql_num_rows($result) == 1) {
            	// previous player list was already approved
            	$row = mysql_fetch_assoc($result);
                $oldPlayerListId = $row['player_list_id'];
                $result = mysql_query("SET AUTOCOMMIT=0", $connect);
			    $result = mysql_query("BEGIN", $connect);
			    $query = "select date_added from zt_player_list where player_list_id = ".$oldPlayerListId;
			    $result = mysql_query($query, $connect);
			    $row = mysql_fetch_assoc($result);
			    $dateAdded =$row['date_added'];
				$query = "update zt_player_list set date_approved = now(), date_modified = date_added, 
					date_added = '".$dateAdded."' where player_list_id = ".$playerListId;
				if ($result = mysql_query($query, $connect)) {
					$query = "update zt_player_list set inactive = 1 where player_list_id = ".$oldPlayerListId;
					mysql_query($query, $connect);
                    // NOT NEEDED ANYMORE SINCE PL'S ARE VERSIONED IN GAMES
					/*$query = "delete from zt_player where player_list_id = ".$oldPlayerListId;
                    if ($result = mysql_query($query, $connect)) {
                    	$query = "delete from zt_player_list where player_list_id = ".$oldPlayerListId;
	                    if ($result = mysql_query($query, $connect)) {
	                        $result = mysql_query("COMMIT", $connect);
	                    } else {
	                        $result = mysql_query("ROLLBACK", $connect);
	                    }
                    }*/
                }
            } else {
                $query = "update zt_player_list set date_approved = now() where player_list_id = ".$playerListId;
                mysql_query($query, $connect);
            }

            if (mail($to,CURRENT_ZT_TOURNAMENT.': uw spelerslijst is goedgekeurd !',$body, $headers) == true) {
                 $msg = "Spelerslijst club goedgekeurd. Mailconfirmatie verzonden naar ".$to." and tornooileider@schaakliga-antwerpen.info.";
			} else {
                 $msg = "Spelerslijst club goedgekeurd. Mailconfirmatie kon niet verzonden worden naar ".$to." en tornooileider@schaakliga-antwerpen.info.";
            }
            flush();

    	} else {

            if (mail($to,CURRENT_ZT_TOURNAMENT.': uw spelerslijst is afgekeurd !',$body, $headers) == true) {
            	$msg = "Spelerslijst club afgekeurd. Mailconfirmatie verzonden naar ".$to." and tornooileider@schaakliga-antwerpen.info.";
			} else {
                $msg = "Spelerslijst club afgekeurd. Mailconfirmatie kon niet verzonden worden naar ".$to." en tornooileider@schaakliga-antwerpen.info.";
            }
            flush();

        }
        $_SESSION['mailMessage'.$playerListId] = null;

        // UPDATING LIST on DATABASE

        $result = mysql_query("SET AUTOCOMMIT=0", $connect);
        $result = mysql_query("BEGIN", $connect);
        
    	if (isset($changed)) {
        	// refresh list with latest changes
        	//$playersListApprove = $_SESSION['players'.$playerListId];
        	// tornooileider maakte wijzigingen aan lijst
            $query = "DELETE FROM zt_player WHERE player_list_id = ".$playerListId;
        	$result = mysql_query($query, $connect);
        }

        $nrOfInsertedPlayers = 0;
        while ($player = current($playersListApprove)) {
            if (!empty($player->player_key)) {
                // existing player
                $query = sprintf("SELECT matricule from playernew where matricule = %u", $player->player_key);
                $result = mysql_query($query, $connect);
                $row = mysql_fetch_assoc($result);
                
	            $playerId = $row['matricule'];
	            $indexNr = key($playersListApprove);
	
	            if (!empty($player->team_name)) {
	                $query = sprintf("SELECT team_id from zt_team where team_nr = %d and club_id = %u and tournament_id = %u",
	                    $player->team_name, $clubId, $currentTournament);
	                $result = mysql_query($query, $connect);
	                $row = mysql_fetch_assoc($result);
	                $teamId = $row['team_id'];
	
	                $query = sprintf("INSERT INTO zt_player(player_key, player_list_id, team_id, index_nr) VALUES (%u, %u, %u, %u)",
	                    $playerId, $playerListId, $teamId, $indexNr+1);
	
	                if ($result = mysql_query($query, $connect)) {
	                    if (mysql_affected_rows($connect) == 1) {
	                        $nrOfInsertedPlayers = $nrOfInsertedPlayers + 1;
	                    }
	                }
	
	            } else {
	                $query = sprintf("INSERT INTO zt_player(player_key, player_list_id, index_nr) VALUES (%u, %u, %u)",
	                    $playerId, $playerListId, $indexNr+1);
	
	                if ($result = mysql_query($query, $connect)) {
	                    if (mysql_affected_rows($connect) == 1) {
	                        $nrOfInsertedPlayers = $nrOfInsertedPlayers + 1;
	                    }
	                }
	            }
                
            } else {
                $result = mysql_query("ROLLBACK", $connect);
                $msg = "Nieuwe speler '".$player->player_name."' niet opgeslagen. Contacteer de webmaster -> debug=[".$query."]";
    			redirect("/tornooien/zt-php/view_players_list.php?msg=".$msg);
            }

            next($playersListApprove);
        }

        if ($nrOfInsertedPlayers == count($playersListApprove) ) {
            $result = mysql_query("COMMIT", $connect);
            $msg .= " Spelerslijst gewijzigd.";
            unset($_SESSION['players'.$playerListId]);
        } else {
            $result = mysql_query("ROLLBACK", $connect);
            $msg .= " Wijzigingen aan spelerslijst konden niet opgeslagen worden.";
        } 
        
        redirect("/tornooien/zt-php/view_players_list.php?msg=".$msg);
    }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Tornooien</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../../assets/css/default.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../../assets/js/ajax.js" />
</script>
</head>

<body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0" class="default">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td>
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="7">
                        <img src="../../assets/images/spacer.gif" height="1" width="7" ALT="">
                    </td>
                    <td width="150" align="left"><img src="../../assets/images/headerbar_kerst.gif" alt="" ></td>

                </tr>
                <tr>
                    <td colspan="2" height="12"><img src="../../assets/images/spacer.gif" alt="" height="12" width="1"></td>
                </tr>
            </table>
        </td>
        <td align="right" valign="top">
		<br/>
        <a href="../../logout.php?redirect=/tornooien/zt-php/view_players_list.php"><img src="../../assets/images/24x24/plain/exit.gif" border="0" alt="Log uit"></a>
		<br>&nbsp;<br>
		<span class="headerSmall">User <?=$_SESSION['user']->name?> logged in at <?=$user->login_date?>.</span>
		</td>
		<td>&nbsp;</td>
	</tr>
</table>

<table border="0" cellpadding="0" cellspacing="0" width="100%" >
    <tr>
        <td align="left">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td rowspan="2" width="7"><img src="../../assets/images/spacer.gif" alt="" height="1" width="7"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
					<td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/newsbox.php" target="_top"><span class="tabName">Nieuwsbox</span></a></td>
					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
					<td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_FFFFFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="activeSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/tornooien/tornooien.html" target="_top"><span class="tabName">Tornooien</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_FFFFFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/bestuur/bestuur.php" target="_top"><span class="tabName">Bestuur</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/advalvas/index.html" target="_top"><span class="tabName">Ad Valvas</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="http://www.frbe-kbsb.be/EloHist/FRBE_Fiche.php" target="_blank"><span class="tabName">ELO</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/clubs/clubs.php" target="_top"><span class="tabName">Clubs</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/jeugd/index.html" target="_top"><span class="tabName">Jeugd</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>

					<td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_l.gif" height="14" width="14" ALT=""></td>
                    <td nowrap rowspan="2" class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt="" height="3" width="3"><br/><a href="/links/index.php" target="_top"><span class="tabName">Links</span></a></td>
                    <td valign="top"><img src="../../assets/images/tabcorners/re_99CCFF_r.gif" height="14" width="14" ALT=""></td>
                    <td rowspan="2" width=2><img src="../../assets/images/spacer.gif" alt="" height="1" width="2"></td>
				</tr>
				<tr>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="activeSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="activeSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
					<td class="inactiveSpacer"><img src="../../assets/images/spacer.gif" alt=""></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td width="100%" bgcolor="#FFFFFF" colspan="13"><img border="0" width="30" src="../../assets/images/FFFFFF.gif" height="12" alt=""></td>
	</tr>
</table>

<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0" bgcolor="#FFFFFF">
	<tr>
		<td id="leftFiller" valign="top" height="100%" rowspan="3" bgcolor="#666666">
			<table border="0" cellpadding="0" cellspacing="0" height="100%" width="8px">
				<tr><td>&nbsp;</td></tr>
			</table>
		</td>
		<td id="header" valign="top" width="100%">
			<table border="0" width="100%" cellpadding="3" cellspacing="0" bgcolor="#10425b">
                <tr>
                    <td bgcolor="#666666" width="40%">
                        <?php include("inc_title.html"); ?>
                    </td>
                    <td bgcolor="#666666" align="right" valign="top">&nbsp;
                          <span class="headerSmall">Huidige versie PLAYER.DBF: <?=CURRENT_PLAYER_DBF?>
                        <?php
                        if (isset($user) && $user->club_id == 100) {
                        ?>
                        <br/>
                        <a class="headerSmall" href="import_player.php">laad andere versie</a>
                        <?php
                        }
                        ?>
                        </span>
                    </td>
                </tr>
            </table>
            <table align="center" border="0" width="100%" height="90%" cellpadding="0" cellspacing="0" style="border-top:#BCDD10 4px solid;">
                <tr>
                    <?php include("inc_sublinks.php"); ?> 
                </tr>
				<tr><td colspan="2" nowrap bgcolor="#BCDD10" height="4"><img src="../../assets/images/spacer.gif" alt="" height="1" width="1"></td></tr>
				<tr>
					<td>&nbsp;</td>
					<td valign="top">
						<table align="left" cellspacing="10" width="100%">
							<tr>
								<td>
                                    <span class="blackHeaderLarge"><?=CURRENT_ZT_TOURNAMENT?> - Validatie spelerslijst <?=$clubname?></span>
									<br>&nbsp;<br>
                                    <a href="view_players_list.php"><img src="../../assets/images/24x24/shadow/document.gif" border="0" alt="Ga naar overzicht spelerslijsten"/></a>
                                    &nbsp;&nbsp;
                                    <a href="approve_player_list.php?player_list_id=<?=$playerListId?>&action=reset"><img src="../../assets/images/24x24/shadow/recycle.gif" border="0" alt="Reset spelerslijst"/></a>
                                    &nbsp;&nbsp;
                                    <strong>Ploegleider : <?=$name?>, <?=$function?>, <a href="mailto:<?=$to?>"><?=$to?></a></strong>
                                    <span class="hidden" id="noValidTeam">Ploegnummertoewijzing is niet geldig voor deze speler.</span>
                                    <span class="hidden" id=playerListCommentNotStored>Commentaar op spelerslijst niet opgeslagen.</span>
                                    <br>&nbsp;<br>
                                    <table width="70%" border="0" cellpadding="0" cellspacing="0" id="test">
                                        <?php
                                    		if (count($playersListApprove) == 0) {
                                        ?>
                                        <tr>
											<td colspan="11"><strong>Deze spelerslijst bevat nog geen spelers.</strong></td>
										</tr>
                                        <?php
                                            } else {
                                        ?>
                                        <tr>
											<td width="5%"><strong>Volgnr</strong></td>
											<td width="10%" align="center"><strong>Stamnr</strong>&nbsp;&nbsp;</td>
											<td width="5%" align="center"><strong>Ploegnr</strong></td>
											<td width="60%"><strong>Naam</strong></td>
											<td width="10%" align="center"><strong>ELO</strong></td>
											<td width="10%" align="center"><strong>Kring</strong></td>
											<td>&nbsp;</td>
											<td>&nbsp;</td>
											<td>&nbsp;</td>
											<td>&nbsp;</td>
										</tr>
										<form id="playerListForm" action="approve_player_list.php" method="POST">
										<?php
                                            	$row = null;
        										if ( isset($_GET['row']) == true ) $row = $_GET['row'];

                                           		while ($player = current($playersListApprove)) {
                                            		$indexNr = key($playersListApprove);
                                        	?>
                                        <tr>
                                            <td align="center"><strong><?=$indexNr + 1?></strong></td>
                                            <td class="clsTableInputForm" align="center"><input size="10" name="playerKey_<?=key($playersListApprove) + 1?>" class="clsInputForm" value="<?=$player->player_key?>"></td>
                                            <td class="clsTableInputForm" align="center"><input size="10" name="teamName_<?=key($playersListApprove) + 1?>" class="clsInputForm" value="<?=$player->team_name?>"  onblur="storePlayerTeam(this.value,<?=$playerListId?>,<?=$clubId?>,<?=$indexNr + 1?>,'')" /></td>
                                            <td><span class="default" id="playerName_<?=key($playersListApprove) + 1?>" name="playerName_<?=key($playersListApprove) + 1?>">&nbsp;&nbsp;<?=$player->player_name?></span></td>
                                            <td align="center"><span class="default" id="playerElo_<?=key($playersListApprove) + 1?>" name="playerElo_<?=key($playersListApprove) + 1?>">&nbsp;&nbsp;<?=$player->elo?></span></td>                                            
                                            <td align="center"><span class="default" id="playerClub_<?=key($playersListApprove) + 1?>" name="playerClub_<?=key($playersListApprove) + 1?>">&nbsp;&nbsp;<?=$player->club_id?></span></td>
                                            <td align="center">&nbsp;&nbsp;<a href="approve_player_list.php?player_list_id=<?=$playerListId?>&row=<?=$indexNr + 1?>&action=remove"><img border="0" src="../../assets/images/16x16/shadow/delete2.gif"></a></td>
                                            <?php
                                            	    if($indexNr != 0) { // first row
	                                        ?>
	                                                <td align="center">&nbsp;&nbsp;<a href="approve_player_list.php?player_list_id=<?=$playerListId?>&row=<?=$indexNr + 1?>&action=up"><img border="0" src="../../assets/images/16x16/shadow/arrow_up_green.gif"></a></td>
	                                        <?php
	                                                } else {
	                                        ?>
	                                                <td>&nbsp;</td>
	                                        <?php
	                                                }
	                                                if($indexNr + 1 != count($playersListApprove)) { // row is not last row
	                                        ?>
	                                                <td align="center">&nbsp;&nbsp;<a href="approve_player_list.php?player_list_id=<?=$playerListId?>&row=<?=$indexNr + 1?>&action=down"><img border="0" src="../../assets/images/16x16/shadow/arrow_down_blue.gif"></a></td>
	                                        <?php
	                                                } else {
	                                        ?>
	                                                <td>&nbsp;</td>
	                                        <?php
	                                                }
	                                        ?>
	                                            </tr>
	                                        <?php
                                                	next($playersListApprove);
	                                    		}
                                        	}
										?>
										<tr>
											<td colspan="6">&nbsp;</td>
										</tr>
									</table>
									<textarea name="comment" rows="10" cols="130" onblur="storeComment(this.value,<?=$playerListId?>,'')"></textarea>
                                    &nbsp;&nbsp;
                                    <a href="approve_player_list.php?player_list_id=<?=$playerListId?>&approval=true"><img src="../../assets/images/24x24/shadow/check2.gif" border="0" alt="Keur spelerslijst goed"/></a>
                                    &nbsp;&nbsp;
                                    <a href="approve_player_list.php?player_list_id=<?=$playerListId?>&approval=false"><img src="../../assets/images/24x24/shadow/delete2.gif" border="0" alt="Keur spelerslijst af"/></a>
                                    <br>&nbsp;<br>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
			</table>
		</td>
	</tr>
</table>

</body>
</html>
